<template>
  <!-- 移动端的搜索框组件 （没想到叭竟然在这 哈哈哈哈） -->
  <div class="search-input">
    <input
      v-model="keyword"
      type="text"
      @keyup.enter="searchHandler"
      placeholder="搜索..."
    />
    <label @click="searchHandler">Go</label>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  name: "SearchInput",
  data() {
    return {
      keyword: "",
    };
  },
  methods: {
    ...mapActions("music", ["searchRequest"]),
    searchHandler() {
      if (!this.keyword)
        return this.$message({ message: "请输入搜索关键字！", duration: 1000 });
      this.searchRequest(this.keyword);
      this.keyword = "";
    },
  },
};
</script>

<style lang="less" scoped>
.search-input {
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  background: #2f2f2f;
  padding: 0.5rem 0.4rem;
  padding-right: 2rem;
  padding-left: 0.8rem;
  font-size: 0.3rem;
  position: relative;
  display: flex;
  justify-content: center;
  display: none;
  input {
    width: 100%;
    height: 38px;
    outline: none;
    border: 0;
    background: rgb(255, 255, 255);
    color: #2f2f2f;
    padding-left: 0.2rem;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
  }
  label {
    position: absolute;
    cursor: pointer;
    right: 1rem;
    z-index: 1;
    background-color: #57be84;
    height: 38px;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2f2f2f;
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
  }
}
@media screen and (max-width: 992px) {
  .search-input {
    display: flex;
  }
}
</style>